/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.applicatioN.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Slim
 */
@Entity
@Table(name = "certification")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Certification.findAll", query = "SELECT c FROM Certification c"),
    @NamedQuery(name = "Certification.findByReputation", query = "SELECT c FROM Certification c WHERE c.reputation = :reputation"),
    @NamedQuery(name = "Certification.findByOrganisme", query = "SELECT c FROM Certification c WHERE c.certificationPK.organisme = :organisme"),
    @NamedQuery(name = "Certification.findByDomaineDExpertise", query = "SELECT c FROM Certification c WHERE c.certificationPK.domaineDExpertise = :domaineDExpertise")})
public class Certification implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CertificationPK certificationPK;
    @Basic(optional = false)
    @Column(name = "REPUTATION")
    private int reputation;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "certification")
    private Collection<Recevoir> recevoirCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "certification")
    private Collection<Exiger3> exiger3Collection;

    public Certification() {
    }

    public Certification(CertificationPK certificationPK) {
        this.certificationPK = certificationPK;
    }

    public Certification(CertificationPK certificationPK, int reputation) {
        this.certificationPK = certificationPK;
        this.reputation = reputation;
    }

    public Certification(String organisme, String domaineDExpertise) {
        this.certificationPK = new CertificationPK(organisme, domaineDExpertise);
    }

    public CertificationPK getCertificationPK() {
        return certificationPK;
    }

    public void setCertificationPK(CertificationPK certificationPK) {
        this.certificationPK = certificationPK;
    }

    public int getReputation() {
        return reputation;
    }

    public void setReputation(int reputation) {
        this.reputation = reputation;
    }

    
    @XmlTransient
    public Collection<Recevoir> getRecevoirCollection() {
        return recevoirCollection;
    }

    public void setRecevoirCollection(Collection<Recevoir> recevoirCollection) {
        this.recevoirCollection = recevoirCollection;
    }

    @XmlTransient
    public Collection<Exiger3> getExiger3Collection() {
        return exiger3Collection;
    }

    public void setExiger3Collection(Collection<Exiger3> exiger3Collection) {
        this.exiger3Collection = exiger3Collection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (certificationPK != null ? certificationPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Certification)) {
            return false;
        }
        Certification other = (Certification) object;
        if ((this.certificationPK == null && other.certificationPK != null) || (this.certificationPK != null && !this.certificationPK.equals(other.certificationPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.applicatioN.entities.Certification[ certificationPK=" + certificationPK + " ]";
    }
    
}
